<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
%>
<%@page import="java.util.List, manager.*,book.*, member.*" %>
<%
	// リクエスト文字列のエンコードを設定
	request.setCharacterEncoding("UTF-8");
	// パラメータの取得
	Integer crtPage = (Integer)request.getAttribute("page");
	Integer cnt = (Integer)request.getAttribute("cnt");
	if(cnt==null)
	{
		cnt=0;
	}
	String msg = String.format("該当 %d件です", cnt);


	@SuppressWarnings("unchecked")
	List<ReserveBean> list = (List<ReserveBean>)request.getAttribute("list");
	@SuppressWarnings("unchecked")
	List<BookBean> listAppend = (List<BookBean>)request.getAttribute("listAppend");
	@SuppressWarnings("unchecked")
	List<MemberBean> listAppend2 = (List<MemberBean>)request.getAttribute("listAppend2");

	ReserveBean reserves = new ReserveBean();
	BookBean books = new BookBean();
	MemberBean members = new MemberBean();
	RentalBean rentals = new RentalBean();

%>
<jsp:include page="/share/layout.jsp" flush="true">
    <jsp:param name="title" value="予約者一覧"/>
    <jsp:param name="css" value="member.css"/>
        <jsp:param name="content" >
        <jsp:attribute name="value">
<!-- contents start -->
<% if(list!=null) { %>

<% if(msg != null && !"".equals(msg)) { %>
<div style="font-weight:bold;">
	<%= msg %>
</div>
<% } %>

	<form action="/Books/member/MailEditServlet" method="get">
		<table class="form_table">
			<tr>
				<th style="width:5px"></th>
				<th>メールアドレス</th>
				<th>氏名</th>
				<th>フリガナ</th>
				<th>タイトル</th>
				<th>ISBN</th>
				<th>予約日</th>
			</tr>

		<%
			for(int i=0; i<list.size(); i++) {
			reserves = list.get(i);
			books =listAppend.get(i);
			members = listAppend2.get(i);

			if(reserves.isMailFlag() == false) {
		%>
			<tr>
				<td>
					<input type="radio" name="id" value="<%= reserves.getId() %>" />
				</td>
				<td>
					<%= members.getUserId() %>
				   <%--<input type="hidden" name ="member_id" value=<%= members.getId() %>/> --%>
				</td>
				<td>
					<%= members.getName() %>
				</td>
				<td>
					<%= members.getRuby() %>
				</td>
				<td>
					<%= books.getTitle() %>
				</td>
				<td>
					<%= reserves.getBookIsbn() %>
				</td>
				<td align="center">
					<%= reserves.getReserveDate() %>
				</td>
			</tr>
		<%
			}
			else
			{
				%>
				<tr class="delete">
				<td>
					<input type="radio" name="id" value="<%= reserves.getId() %>" />
				</td>
				<td>
					<%= members.getUserId() %>
				   <%--<input type="hidden" name ="member_id" value=<%= members.getId() %>/> --%>
				</td>
				<td>
					<%= members.getName() %>
				</td>
				<td>
					<%= members.getRuby() %>
				</td>
				<td>
					<%= books.getTitle() %>
				</td>
				<td>
					<%= reserves.getBookIsbn() %>
				</td>
				<td align="center">
					<%= reserves.getReserveDate() %>
				</td>
			</tr>
			<%
			}
		}
	%>
		</table>

	<div id="paging_area">
		<% if(crtPage > 1) { %>
			<a href="/Books/member/ReserveListServlet?page=<%= crtPage-1 %>">前へ</a>
		<% } %>
		<% for(int i=0, p=1; i<cnt; i+=10, p++) { %>
			<a href="/Books/member/ReserveListServlet?page=<%= p %>"><%= p %></a>
		<% } %>
		<% if(crtPage * 10 < cnt) { %>
			<a href="/Books/member/ReserveListServlet?page=<%= crtPage+1 %>">次へ</a>
		<% } %>
	</div>
<%}

else { %>
	<div id="msg_area">
	<%= msg %>
</div>
	<h3 align="center">リストがありません</h3>
<%} %>

	 <input type="button" value="戻る" class="button" style="cursor:pointer" onClick="history.back(); return false;">
	 <input class="button" type="submit" name="reserve" value="メール編集" />
	 <input class="button" type="submit" name="rental" value="貸出" />

	</form>

<!-- contents end -->
        </jsp:attribute>
    </jsp:param>
</jsp:include>

